home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1993 November / 1993-11.d64 / unbrkable cipher (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  27KB  |  791 lines

  1. 100 dv=peek(186):if dv<8 then dv=8
  2. 105 poke53280,6:poke53281,6:printchr$(14)chr$(8):b=0
  3. 110 gosub840
  4. 115 dimx(300),p$(10,10,10)
  5. 120 print"[147][212]he main menu is:":print
  6. 125 print"[159]1[146]  [201]ntroduction (recommended reading)":print
  7. 130 print"[159]2[146]  [196]emonstration of computer enciphering";:print
  8. 135 print"[159]3[146]  [196]emonstration of computer deciphering"
  9. 140 print"[159]4[146]  [208]rinting cipher sheets":print
  10. 145 print"[159]5[146]  [197]xit to [199]azette [196]isk":print
  11. 150 print"[195]hoose [159]1[146] to [159]5[146]."
  12. 155 geta$:ifa$<>"1"anda$<>"2"anda$<>"3"anda$<>"4"anda$<>"5"then155
  13. 160 ifa$="1"then200
  14. 165 ifa$="2"then970
  15. 170 ifa$="3"then1895
  16. 175 ifa$="4"then2675
  17. 180 ifa$="5"thenprint"[147][196]o you wish to quit?  (y/n)"
  18. 185 geta$:ifa$<>"y"anda$<>"[217]"anda$<>"n"anda$<>"[206]"then185
  19. 190 ifa$="y"ora$="[217]"then785
  20. 195 ifa$="n"ora$="[206]"then120
  21. 200 print"[147][159]         [212]he [213]nbreakable [195]ipher"
  22. 205 print"           by [202]ames [212]. [202]ones  ":print
  23. 210 print"[201]n cryptography there is a technique":print
  24. 215 print"for enciphering plaintext called the":print
  25. 220 print"one-time sheet (or ots).  [212]he basic":print
  26. 225 print"idea underlying the method is to use":print
  27. 230 print"random arrays of letters, numbers,":print
  28. 235 print"spaces and punctuation marks (if any) by"
  29. 240 print"means of which ciphertext is prepared."
  30. 245 print"[159][208]ress <space> to continue."
  31. 250 geta$:ifa$<>" "then250
  32. 255 print"[147][206]o element of the arrays is ever":print
  33. 260 print"used more than once.  [193] statistical":print
  34. 265 print"analysis of the occurrences of elements":print
  35. 270 print"or the numbers representing them":print
  36. 275 print"will therefore not readily yield":print
  37. 280 print"useful information for breaking the":print
  38. 285 print"cipher.":print
  39. 290 print"[212]he person preparing the cipher-":print
  40. 295 print"text and the recipient(s) are":print
  41. 300 print"assumed to have duplicate copies":print
  42. 305 print"of the cipher arrays."
  43. 310 print"[159][208]ress <space> to continue."
  44. 315 geta$:ifa$<>" "then315
  45. 320 print"[147]":restore:a=0:gosub680
  46. 325 print"[204]et us consider a specific example.":print
  47. 330 print"[193] set of arrays can consist of up to":print
  48. 335 print"ten arrays numbered from 0 to 9.  [197]ach":print
  49. 340 print"array consists of ten columns (0-9)":print
  50. 345 print"and ten rows (0-9)."
  51. 350 print"[159][208]ress <space> to continue."
  52. 355 geta$:ifa$<>" "then355
  53. 360 print"[147]":restore:a=0:gosub680
  54. 365 print"[196]ifferent sets of arrays are numbered";:print
  55. 370 print"sequentially beginning with 1.  [201]n this":print
  56. 375 print"example, the set of arrays consists of":print
  57. 380 print"a single array, array 0[146].":print
  58. 385 print"[159][208]ress <space> to continue."
  59. 390 geta$:ifa$<>" "then390
  60. 395 print"[147]":restore:a=0:gosub680
  61. 400 print"[212]he element of array 0[146] corresponding":print
  62. 405 print"to [158]row 0 and [158]column 0 is the number "chr$(34)"2"chr$(34)"."
  63. 410 print"[212]he element corresponding to [158]row 8 and":print
  64. 415 print"[158]column 5 is "chr$(34)"l"chr$(34)".
  65. 420 [153]"open       (NULL)ress <space> to continue"
  66. 425 [161]a$:[139]a$[179][177]" "[167]425
  67. 430 [153]"load":[140]:a[178]0:[141]680
  68. 435 [153]"atnn element in a given array is speci-";:[153]
  69. 440 [153]"fied by sys(a)(r)(c) where sys(a), sys(r), and":[153]
  70. 445 [153]"sys(c) are the array number, row number and";:[153]
  71. 450 [153]"column number, respectively.  left$ence, sys076";:[153]
  72. 455 [153]"would represent "[199](34)"o"[199](34)" in the above array."
  73. 460 [153]"open(NULL)ress <space> to continue."
  74. 465 [161]a$:[139]a$[179][177]" "[167]465
  75. 470 [153]"loadvalnciphered characters are repre-":[153]
  76. 475 [153]"sented by three-digit groups, of the ":[153]
  77. 480 [153]"form sys(a)(r)(c), written adjacently":[153]
  78. 485 [153]"without intervening spaces. ascor example,"
  79. 490 [153]"sys012145 would represent two three-digit":[153]
  80. 495 [153]"groups of the form":[153]
  81. 500 [153]"sys(a1)(r1)(c1)(a2)(r2)(c2)":[153]
  82. 505 [153]"with sys(a1)=0,sys (r1)=1,sys (c1)=2, sys(a2)=1,":[153]
  83. 510 [153]"sys(r2)=4 and sys(c2)=5."
  84. 515 [153]"open(NULL)ress <space> to continue."
  85. 520 [161]a$:[139]a$[179][177]" "[167]520
  86. 525 [153]"load":[140]:a[178]0:[141]680
  87. 530 [153]"right$n the above array, the six-digit":[153]
  88. 535 [153]"group, sys013029, represents the word "[199](34)"it"[199](34)"."
  89. 540 [153]"(NULL)he element corresponding tosys row 1,":[153]
  90. 545 [153]"syscolumn 3 is "[199](34)"i"[199](34)".  sys(NULL)ow 2 and syscolumn 9":[153]
  91. 550 [153]"specify the element "[199](34)"t"[199](34)"."
  92. 555 [153]"open(NULL)ress <space> to continue."
  93. 560 [161]a$:[139]a$[179][177]" "[167]560
  94. 565 [153]"load(NULL)o element of a given array should"
  95. 570 [153]"ever be used more than once, because"
  96. 575 [153]"repetition of its row and column could"
  97. 580 [153]"conceivably assist in breaking the"
  98. 585 [153]"cipher.  right$f the same number or letter"
  99. 590 [153]"is used multiple times, different"
  100. 595 [153]"array numbers, rows and columns are"
  101. 600 [153]"found successively for enciphered"
  102. 605 [153]"representation.  right$n this way, for a"
  103. 610 [153]"given array, a particular row and"
  104. 615 [153]"column are used once and only once."
  105. 620 [153]"(NULL)hen using printed arrays, always"
  106. 625 [153]"cross off each element as it is used."
  107. 630 [153]"(NULL)his program requires that plain-"
  108. 635 [153]"text be entered using only lower case"
  109. 640 [153]"letters of the valnglish alphabet and"
  110. 645 [153]"the numbers 0 to 9.  (NULL)o spaces are"
  111. 650 [153]"allowed.  (NULL)ubroutines have been intro-"
  112. 655 [153]"duced to accomplish this purpose."
  113. 660 [151]214,21:[153]
  114. 665 [153]"open(NULL)ress <space> to return to main menu"
  115. 670 [161]a$:[139]a$[179][177]" "[167]670
  116. 675 [137]120
  117. 680 [153]"loadopenset of arrays #" 1:[153]
  118. 685 [153]"openoncolumn--->sys0 1 2 3 4 5 6 7 8 9 "
  119. 690 [129]r[178]0[164]9:[129]c[178]0[164]9
  120. 695 [135] p$(a,r,c)
  121. 700 [130]c,r
  122. 705 [129] r[178]0 [164] 9
  123. 710 [153]"sys"[166]09)r;:[129] c[178]0[164]9
  124. 715 [153]" "p$(a,r,c);:[130]c:[153]
  125. 720 [130] r
  126. 725 [153]"ononononononarray" 0"wait"
  127. 730 [131] 2,e,s,p,r,g,m,z,z,t
  128. 735 [131] u,a,z,i,y,v,p,w,a,k
  129. 740 [131] 9,m,v,a,n,q,s,b,9,t
  130. 745 [131] m,g,o,h,5,f,1,z,f,o
  131. 750 [131] s,1,b,q,h,8,o,2,9,w
  132. 755 [131] 9,s,r,4,u,4,y,5,l,3
  133. 760 [131] n,7,r,c,p,a,g,b,6,q
  134. 765 [131] p,1,3,y,1,3,o,d,m,s
  135. 770 [131] a,5,d,g,n,l,z,5,6,0
  136. 775 [131] 4,u,3,d,v,1,x,e,j,g
  137. 780 [142]
  138. 785 [143] exit to gazette disk for 64         users
  139. 790 [153]"loadpeeke sure the chr$azette str$isk is in":[153]
  140. 795 [153]"the disk drive and press sys<(NULL)val(NULL)(NULL)(NULL)(NULL)>."
  141. 800 [161]a$:[139]a$[179][177][199](13)[167]800
  142. 805 [160]15:[159]15,dv,15,"r0:menu=menu":[132]15,e:[160]15:[139]e[179][177]63[167]830
  143. 810 [153]"load":[151]214,12:[153]:[153]"(NULL)oading (NULL)enu of chr$azette str$isk for 64":[153]
  144. 815 [153]"(NULL)sers....(NULL)lease standby...":[129]t[178]1[164]5000:[130]
  145. 820 [151]646,[194](53281):[153]"load"[199](34)"menu"[199](34)","dv",1"
  146. 825 [151]631,13:[151]198,1:[128]
  147. 830 [153]"(NULL)orry!  (NULL)he file "[199](34)"menu"[199](34)" was not found!":[128]
  148. 835 [143] format a disk
  149. 840 [153]"load(NULL)his program requires a newly":[153]
  150. 845 [153]"formatted disk or a disk with at least":[153]
  151. 850 [153]"100 blocks free.":[153]
  152. 855 [153]"str$o you wish to format a disk?  (y/n)":[153]
  153. 860 [161]a$:[139]a$[179][177]"y"[175]a$[179][177]"(NULL)"[175]a$[179][177]"n"[175]a$[179][177]"(NULL)"[167]860
  154. 865 [139]a$[178]"n"[176]a$[178]"(NULL)"[167]115
  155. 870 [153]"load(NULL)emove the chr$azette str$isk from the":[153]
  156. 875 [153]"the disk drive and insert the disk":[153]
  157. 880 [153]"to be formatted.":[153]
  158. 885 [141]3420:[141]3355
  159. 890 [153]"syslenaution: the disk will be erased.":[153]
  160. 895 [153]"peeke sure the disk drive is powered and":[153]
  161. 900 [153]"properly connected.  (NULL)lease press":[153]
  162. 905 [153]"(NULL)val(NULL)(NULL)(NULL)(NULL)waitsys to proceed with formatting":[153]
  163. 910 [153]"when the disk drive is ready."
  164. 915 [161]a$:[139]a$[179][177][199](13)[167]915
  165. 920 [153]"(NULL)ame of disk:wait":[15